package com.tender.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tender.facade.StockFacadeSentinelApi;

import java.util.UUID;

@RestController
@RefreshScope // 以 这个bean 为单位，可以动态感知里面的属性的变化
public class OrderController {

    @Autowired
    private StockFacadeSentinelApi stockFacadeSentinelApi;

    @Value("${server.port}")
    private String port;

    @GetMapping("/prepare/order")
    public String prepareOrder() {
        return stockFacadeSentinelApi.checkStockInfoByNo(UUID.randomUUID().toString());
    }

    @GetMapping("/place/order")
    public String placeOrder() {
        return stockFacadeSentinelApi.deduceStockByOrderNo(UUID.randomUUID().toString());
    }

}
